package com.example.a22310.myapplication.Model;

import android.provider.MediaStore;

import com.example.a22310.myapplication.Beans.Club;
import com.example.a22310.myapplication.Listener.ClubListener;
import com.example.a22310.myapplication.Service.service;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static android.provider.ContactsContract.CommonDataKinds.Website.URL;

public class ClubModel {
    private Retrofit retrofit;
    public ClubModel()
    {
        retrofit= new Retrofit.Builder()
                .baseUrl(URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }

    public void clubList(final ClubListener<Club> listener) {  //俱乐部列表
        service userService = retrofit.create(service.class);
        Call<Club> call = userService.clublist();
        Callback<Club> callback = new Callback<Club>() {
            @Override
            public void onResponse(Call<Club> call, Response<Club> response) {
                Club club = response.body();
                listener.onSuccess(club);
            }
            @Override
            public void onFailure(Call<Club> call, Throwable t) {
                listener.onFailure();
            }
        };
        call.enqueue(callback);
    }




}
